/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef _IMAGE_FILE_READER_HPP
#define _IMAGE_FILE_READER_HPP

#include "owndebug.h"
#include <string>
#include "ImageData.hpp"
#include "ImageContainer.hpp"
#include "JPEGDecoder.hpp"
#include "gimutils.h"
#include "ownutils.h"
#include <map>
#include <list>
#include <string>
#include <stdio.h>
typedef  std::map<gim::time,std::vector<unsigned int> > TImageDataTimeMap;

class CImageFileReader{
public:
  /**
   * Constructor
   */
  CImageFileReader();

  /**
   * Destructor
   */
  ~CImageFileReader();

  /**
   * Opens file with wanted filename
   */
  bool ReadFile(std::string aFileName);

  
  bool GetServiceInformation(std::string &aMaCIGroup,
                             std::string &aInstanceName);

  bool GetTimes(std::list<gim::time> &aTimes);

  bool GetTimeLimits(gim::time &aBegin,gim::time &aEnd);
  
  unsigned int GetImageCountPerPacket(void);

  bool GetImageData(MaCI::Image::CImageData &aData,
                    gim::time aTime);
  
  
  
private:
  bool iFileReaded;  
  TImageDataTimeMap iData;
  std::map<gim::time,std::vector<MaCI::Image::TImageInfo> > iImageInfos;
  std::list<gim::time> iTimes;
  gim::time iBegin;
  gim::time iEnd;
  std::string iMaCIGroup;
  std::string iInstanceName;
  char iDirectory[512];
  MaCI::Image::EImageDataType iImageFormat;
  unsigned int iImageCount;
  
  bool ReadData(FILE *iFile);
  
  CImageFileReader( const CImageFileReader&)
  :iFileReaded(false), 
   iData(),
   iImageInfos(),
   iTimes(),
   iBegin(),
   iEnd(),
   iMaCIGroup(""),
   iInstanceName(""),
   iDirectory(),
   iImageFormat(),
   iImageCount(0)
  {}

  CImageFileReader &operator=(const  CImageFileReader&){return *this;}

};
#endif ///< _IMAGE_FILE_READER_HPP
